package no.rodland.acc.chart;

import org.apache.struts2.json.annotations.JSON;
import org.joda.time.DateTime;

/**
 * "x_axis":{
 * "stroke":1,
 * "tick_height":10,
 * "colour":"#d000d0",
 * "grid_colour":"#00ff00",
 * "labels": {
 * "labels": ["January","February","March","April","May","June","July","August","Spetember"]
 * }
 * },
 */
public class X_Axis {
    private Label labels;

    private boolean offset =false;
    private String colour = "#FFFFFF";
    private String gridColour = "#FFFFFF";
    

    @JSON(name="grid-colour")
    public String getGridColour() {
        return gridColour;
    }

    @JSON(name="grid-colour")
    public void setGridColour(String gridColour) {
        this.gridColour = gridColour;
    }

    public String getColour() {
        return colour;
    }

    public void setColour(String colour) {
        this.colour = colour;
    }

    public boolean isOffset() {
        return offset;
    }

    public void setOffset(boolean offset) {
        this.offset = offset;
    }

    public void setDates(int dates) {
        labels = new Label(dates);
    }

    public Label getLabels() {
        return labels;
    }

    public void setLabels(Label labels) {
        this.labels = labels;
    }

    public static class Label {
        private String[] labels;
        private int steps = 4;

        public int getSteps() {
            return steps;
        }

        public void setSteps(int steps) {
            this.steps = steps;
        }

        public Label(int dates) {
            labels = new String[dates];
            DateTime date = new DateTime().minusDays(1);
            for (int i = labels.length - 1; i >= 0; i--) {
                labels[i] = date.toString("dd.MM.yyyy");
                date = date.minusDays(1);
            }
        }

        public String[] getLabels() {
            return labels;
        }

        public void setLabels(String[] labels) {
            this.labels = labels;
        }
    }
}
